package top.superflow.inner.micro.flow.graph

import org.jgrapht.{DirectedGraph, EdgeFactory}
import org.jgrapht.graph.{AbstractBaseGraph, ClassBasedEdgeFactory}
import org.jgrapht.graph.builder.{DirectedGraphBuilder, DirectedGraphBuilderBase}

class ExtFlowNodeGraph[V, E](ef: EdgeFactory[V, E], allowMultipleEdges: Boolean, allowLoops: Boolean)
  extends AbstractBaseGraph[V, E](ef: EdgeFactory[V, E], allowMultipleEdges: Boolean, allowLoops: Boolean)
  with DirectedGraph[V, E] {

  def this(ef: EdgeFactory[V, E]){
    this(ef, false, true)
  }

  def this(edgeClass: Class[_ <: E]) {
    this(new ClassBasedEdgeFactory[V, E](edgeClass));
  }
  

}

object ExtFlowNodeGraph{
  
  def   builder [V, E](edgeClass : Class[_  <: E]) : DirectedGraphBuilderBase[V, E, _ <: ExtFlowNodeGraph[V, E], _] = 
    {
        return new DirectedGraphBuilder[V, E,  ExtFlowNodeGraph[V, E]](new ExtFlowNodeGraph[V, E](edgeClass));
    }
//    public static <V,
//        E> DirectedGraphBuilderBase<V, E, ? <: DefaultDirectedGraph<V, E>, ?> builder(
//            EdgeFactory<V, E> ef)
//    {
//        return new DirectedGraphBuilder<>(new DefaultDirectedGraph<>(ef));
//    }
}